﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Search.aspx.cs" Inherits="WebApplication1.Search" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">

 <style type="text/css">
        .tiaotiao
        {
        	cursor: pointer;
        	display:inline-block;
            padding-left: .5em;
            padding-right: .5em;
            width: 52px;
            height: 24px;
            border: 0;
            background: rgb(56,160,232);
        }
    
    </style>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.scrollablecombo.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#DropDownList_Type').scrollablecombo();
        });
        /*--获取网页传递的参数--*/
        function request(paras) {
            var url = location.href;
            if (url.indexOf("#") > 0)
                url = url.substring(0, url.length - 1);
            var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
            var paraObj = {}
            for (i = 0; j = paraString[i]; i++) {
                paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
            }
            var returnValue = paraObj[paras.toLowerCase()];
            if (typeof (returnValue) == "undefined") {
                return "";
            } else {
                return returnValue;
            }
        }

        function change(select) {
            //alert(select.value);
            //alert(select.options[select.selectedIndex].text);
            //alert(select.nextSibling.href);
            var index = select.nextSibling.href.lastIndexOf("&TagId=");
            if (index != -1) {
                select.nextSibling.href = select.nextSibling.href.substring(0, index);
             }
            select.nextSibling.href += '&TagId=';
            //select.nextSibling.href += select.options[select.selectedIndex].text;
            select.nextSibling.href += select.value;
        }

        function addMarker1(point1, text, description) {
            var marker = new BMap.Marker(point1);
            map.addOverlay(marker);
            var label = new BMap.Label(text, { offset: new BMap.Size(20, -10) });
            marker.setLabel(label);

            var sContent =
            "<div><h4 style='margin:0 0 5px 0;padding:0.2em 0'>" + text + "</h4>" +
            //"<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em;width:200px;'>" + description + "</p>" +
            "<select id='ui_element' onchange='change(this)'><option value='A' selected>-全部-</option><option value='3'>学前教育</option>" +
            "<option value='4'>小学教育</option><option value='5'>初中教育</option><option value='6'>高中教育</option>"+
            "<option value='7'>大学教育</option><option value='8'>专升本</option><option value='9'>留学</option><option value='10'>艺术</option></select>" +
            "<a class='tiaotiao' name='search' href='/SearchResult.aspx?Lo="+point1.lng+"&La="+point1.lat+"'>跳一跳</a>"
            "</div>";

            var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象
            marker.addEventListener("click", function () {
                this.openInfoWindow(infoWindow);
                //图片加载完毕重绘infowindow
            });

        }

        $(document).ready(function () {

            //处理get参数
            if (request("text").length != 0) {
                local.search(request("text"));
                $("#MainContent_TextBox_Search").attr("value", decodeURI(request("text")));
                $("#index_map").slideToggle(500); //窗帘效果的切换,点一下收,点一下开,参数可以无,参数说明同上

            }


            $("#ibSearch").click(function () {
                $("#search").css({ "background": "url(images/bg_h777.gif) repeat-y", "height": "777px" });
                var content = $("#MainContent_TextBox_Search").attr("value");
                local.search(content);
                if ($("#index_map").is(":hidden"))
                    $("#index_map").slideToggle(500); //窗帘效果的切换,点一下收,点一下开,参数可以无,参数说明同上
                return false;
            });
        }); 
    </script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
   
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="maina">
        <img src="images/i1.gif" alt="图片无法显示"/>
    </div>
    <div id="search" class="maina">
        <div id="s_body">
            <span>
                <asp:TextBox ID="TextBox_Search" CssClass="search_input" runat="server" Text="输入您的地址或所在学校" onclick="this.value=''"  ></asp:TextBox>
            </span>
            <%--<span class="a2">
            <asp:DropDownList ID="DropDownList_Type" runat="server" ClientIDMode="Static">
                <asp:ListItem Selected="True">-全部-</asp:ListItem>
                <asp:ListItem>1</asp:ListItem>
                <asp:ListItem>2</asp:ListItem>
                <asp:ListItem>3</asp:ListItem>
                <asp:ListItem>4</asp:ListItem>
            </asp:DropDownList>
              </span>--%>
              <span class="inputb">
                 <asp:ImageButton ID="ibSearch" ImageUrl="images/s2.gif" runat="server" ClientIDMode="Static"/>
              </span>
            <div class="c">
            </div>
        </div>
        <div class="c" id="index_map" style="display:none;">地图插入这里</div>
        <%--<div style="width:520px;height:340px;border:1px solid gray" id="container"></div>--%>
        <script type="text/javascript">
            var map = new BMap.Map("index_map");          // 创建Map实例
            var point = new BMap.Point(121.480425, 31.238047);  // 创建点坐标
            map.centerAndZoom(point, 15);                  // 初始化地图,设置中心点坐标和地图级别。
            map.enableScrollWheelZoom();                  // 启用滚轮放大缩小。
            map.enableKeyboard();                         // 启用键盘操作。
            map.addControl(new BMap.NavigationControl());               // 添加平移缩放控件
            map.addControl(new BMap.ScaleControl());                    // 添加比例尺控件
            map.addControl(new BMap.OverviewMapControl());              //添加缩略地图控

            var options = {
                map: map,
                autoViewport: true,
                onSearchComplete: function (results) {
                    // 判断状态是否正确
                    if (local.getStatus() == BMAP_STATUS_SUCCESS) {
                        var points = [];
                        map.clearOverlays();
                        for (var i = 0; i < results.getCurrentNumPois(); i++) {
                            addMarker1(results.getPoi(i).point, results.getPoi(i).title, results.getPoi(i).address);
                            points.push(results.getPoi(i).point);
                        }
                        //map.getViewport()
                        map.setViewport(points);
                        //map.setCenter(results.getPoi(0).point, 15);                  // 初始化地图,设置中心点坐标和地图级别。
                    }
                }
            };

            var local = new BMap.LocalSearch(map, options);

</script>

        <div id="pic_index" class="c">
            <img src="images/pic/1.gif" alt="图片无法显示"/>
            <img src="images/pic/p2.gif" alt="图片无法显示" />
            <img src="images/pic/p3.gif" alt="图片无法显示" />
            <img  src="images/pic/p4.gif" alt="图片无法显示" />
            <img src="images/pic/pn001.gif" alt="图片无法显示" />
            <img src="images/pic/pn002.gif" alt="图片无法显示" />
            <img src="images/pic/pn003.gif" alt="图片无法显示" />
            <img src="images/pic/pn004.gif" alt="图片无法显示" />
        </div>
    </div>

</asp:Content>
